package com.fyzk.activity.user.accountdetail;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fyzk.base.BaseActivity;
import com.tyjc.lottery.R;
import com.fyzk.net.PublicMethod;
import com.fyzk.view.TopTitleView;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

import java.text.SimpleDateFormat;
import java.util.Date;

import http.DataUtil.text.TextUtil;


/**
 * 帐户明细
 */
@ContentView(R.layout.ac_withdrawrecorddetail)
public class WithDrawRecordDetailActivity extends BaseActivity{

    public static final String STATUSVALUE = "STATUSVALUE";
    TopTitleView withdrawrecord_top;

    public static final  String ID = "ID";
    public static final  String AMOUNT = "AMOUNT";
    public static final  String STARTTIME = "STARTTIME";
    public static final  String FINISHTIME = "FINISHTIME";
    public static final  String DESCRIPTION = "DESCRIPTION";//失败原因
    public static final  String ACCOUNT = "ACCOUNT";
    public static final  String TYPE = "TYPE";
    public static final  String STATUS = "STATUS";


    @ViewInject(R.id.fg_fail)
    FrameLayout fg_fail;
    @ViewInject(R.id.fg_success)
    FrameLayout fg_success;
    @ViewInject(R.id.fg_wait)
    FrameLayout fg_wait;
    @ViewInject(R.id.l_fail_res)
    RelativeLayout l_fail_res;

    @ViewInject(R.id.fg_fail_time)
    TextView fg_fail_time;
    @ViewInject(R.id.fg_success_time)
    TextView fg_success_time;
    @ViewInject(R.id.tag_fail)
    TextView tag_fail;
    @ViewInject(R.id.txt_type)
    TextView txt_type;

    @ViewInject(R.id.txt_withdraw_type)
    TextView txt_withdraw_type;
    @ViewInject(R.id.create_time)
    TextView create_time;
    @ViewInject(R.id.withdraw_account)
    TextView withdraw_account;
    @ViewInject(R.id.withdraw_amount)
    TextView withdraw_amount;
    @ViewInject(R.id.withdraw_status)
    TextView withdraw_status;
    @ViewInject(R.id.withdraw_id)
    TextView withdraw_id;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        withdrawrecord_top = (TopTitleView)findViewById(R.id.withdrawrecord_top);
        withdrawrecord_top.setOnTitleClickListener(this);

        Intent intent = getIntent();

        String id = intent.getStringExtra(this.ID);
        String amount = intent.getStringExtra(this.AMOUNT);
        String startTime = intent.getStringExtra(this.STARTTIME);
        String finishTime = intent.getStringExtra(this.FINISHTIME);
        String description = intent.getStringExtra(this.DESCRIPTION);
        String account = intent.getStringExtra(this.ACCOUNT);
        String type = intent.getStringExtra(this.TYPE);
        String statusme = intent.getStringExtra(this.STATUS);
        int statusv = intent.getIntExtra(this.STATUSVALUE,1);

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        startTime = dateFormat.format(new Date(Long.parseLong(startTime)));
        if(!TextUtil.isEmpty(finishTime)){
            finishTime = dateFormat.format(new Date(Long.parseLong(finishTime)));
        }
        txt_withdraw_type.setText(type);
        txt_type.setText(type);
        create_time.setText(startTime);
        withdraw_account.setText(account);
        withdraw_id.setText(id);
        withdraw_amount.setText(PublicMethod.formatMoney(Double.valueOf(amount)));
//        1	提现成功
//        2	提现失败
//        3	审核成功
//        4	处理中
//        5	未处理
//        6	提现不存在
        withdraw_status.setText(statusme);
        switch (statusv){
            case 1:
                fg_success.setVisibility(View.VISIBLE);
                fg_fail.setVisibility(View.GONE);
                fg_wait.setVisibility(View.GONE);
                l_fail_res.setVisibility(View.GONE);
                fg_success_time.setText(finishTime);
                break;
            case 2:
                fg_success.setVisibility(View.GONE);
                fg_fail.setVisibility(View.VISIBLE);
                fg_wait.setVisibility(View.GONE);
                l_fail_res.setVisibility(View.VISIBLE);
                fg_fail_time.setText(finishTime);
                tag_fail.setText("失败原因："+description);
                break;
            default:
                fg_success.setVisibility(View.GONE);
                fg_fail.setVisibility(View.GONE);
                fg_wait.setVisibility(View.VISIBLE);
                l_fail_res.setVisibility(View.GONE);
                break;
        }



    }




}
